/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2024.
 * Description: Support recording sched_switch and irq events.
 * Author: Chen Zechuan
 * Create: 2023/9/13
 */

static inline int fill_trace_event_type(struct trace_event_call *call)
{
	const char *name;
	size_t len;

	name = trace_event_name(call);
	if (!name)
		return -EINVAL;

	len = strlen(name);
	if (!strncmp(name, "sched_switch", len))
		call->event.type = TRACE_SCHED_SWITCH;
	else if (!strncmp(name, "sched_wakeup", len))
		call->event.type = TRACE_SCHED_WAKEUP;
	else if (!strncmp(name, "sched_wakeup_new", len))
		call->event.type = TRACE_SCHED_WAKEUP_NEW;
	else if (!strncmp(name, "irq_handler_entry", len))
		call->event.type = TRACE_IRQ_HANDLER_ENTRY;
	else if (!strncmp(name, "irq_handler_exit", len))
		call->event.type = TRACE_IRQ_HANDLER_EXIT;
	else if (!strncmp(name, "softirq_entry", len))
		call->event.type = TRACE_SOFTIRQ_ENTRY;
	else if (!strncmp(name, "softirq_exit", len))
		call->event.type = TRACE_SOFTIRQ_EXIT;
	else if (!strncmp(name, "ipi_entry", len))
		call->event.type = TRACE_IPI_ENTRY;
	else if (!strncmp(name, "ipi_exit", len))
		call->event.type = TRACE_IPI_EXIT;

	return 0;
}
